<template>
  <view class="decoration">
    <view class="title">
      <view class="content-title">
        请填写店铺名称并提交
      </view>
      <view class="content-English">
        Please fill in the shop name and submit
      </view>
    </view>
    <view class="fromSubmit">
      <view class="from-item">
        <view class="item-title">
          <text class="from-item-title">店铺名称</text>
          <text class="from-item-English">/Shop Name</text>
        </view>
        <input class="uni-input" v-model="formSubmit.shopName" placeholder="请输入店铺名称" />
      </view>
      <button type="warn" class="from-button" @click="submit">提交 /Submit</button>
    </view>
    <tabBar :currentPage="'tabBar5'"></tabBar>
  </view>
</template>

<script>
import tabBar from '@/components/tabBar.vue'

export default {
  components: {
    tabBar
  },
  data() {
    return {
      formSubmit: {
        shopName: '',
      },
      accessList: []
    }
  },
  methods: {
    submit() {
      if (this.formSubmit.shopName === '') {
        uni.showToast({ title: '店铺名称不能为空', icon: 'none' })
        return
      }
      let params = {
        id: uni.getStorageSync('userInfo').id,
        name: this.formSubmit.shopName
      }
      this.$api.updateShopName(params).then(res => {
        if (res.success) {
          uni.showToast({ title: '提交成功', icon: 'success' })
          setTimeout(() => {
            uni.switchTab({
              url: '/pages/user/user/index'
            })
          }, 500)
        } else {
          uni.showToast({ title: res.msg })
        }
      }).catch(err => {
				console.log('request fail', err)
			})
    }
  }
}
</script>

<style lang="scss" scoped>
.decoration {
  .title {
    padding: 0 0 30rpx 0;
    background: #F6F6F6;
    .content-title {
      text-align: center;
      font-size: 34rpx;
      font-weight: bold;
      color: #333333;
      padding-top: 30rpx;
    }
    .content-English {
      text-align: center;
      padding: 0 80rpx;
      font-size: 28rpx;
      color: #999999;
    }
  }
  .fromSubmit {
    padding: 40rpx;
    .from-item {
      margin-bottom: 40rpx;
      .item-title {
        margin-bottom: 20rpx;
        .from-item-title {
          font-size: 32rpx;
          font-weight: 500;
          color: #333333;
          margin-right: 20rpx;
        }
        .from-item-English {
          font-size: 28rpx;
          font-weight: 500;
          color: #999999;
        }
      }
      .uni-input {
        background: #F6F6F6;
        border-radius:4px;
      }
      .from-item-textarea {
        background: #F6F6F6;
        width: 100%;
        border-radius:4px;
      }
    }
    .from-button {
      background: $uni-color-base;
    }
  }
}
</style>
